#include "command.h"
#include "ui_command.h"
#include "QDate"
#include <QDebug>

Command::Command(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Command)
{
    ui->setupUi(this);
}

Command::~Command()
{
    delete ui;
}

static QString get_time(void)
{
	QDateTime time = QDateTime::currentDateTime();
	QString st = time.toString("[yyyy-MM-dd hh:mm:ss.zzz] ");
	return st;
}

void Command::print_log(QString str)
{
	QString ctime = get_time() + str;
	ui->textBrowser->append(ctime);
	ui->textBrowser->moveCursor(QTextCursor::End);
}

void Command::on_textEdit_textChanged()
{
	QString text = ui->textEdit->toPlainText();
	int end = text.indexOf("\n");
	if(end != -1){
		QString line = text.mid(0,end);
		ui->textEdit->clear();
		qDebug() << "textedit:"<<line<<endl;

		emit recv_js_code(line);

	}
}

